Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compute stats for the main material of the packaging #8662

Merged
merged 20 commits into from
Aug 1, 2023

Conversation

stephanegigandet
Copy link
Contributor

@stephanegigandet stephanegigandet commented Jul 5, 2023

  • for each product, we compute a new field packagings_material_main to indicate the main material (by weight) for the product
  • for each country * category, we compute stats for the main material (as well as stats for the other materials)
  • added a new /api/v3/tag/[tagtype]/[tagid] endpoint to get knowledge panels of a tag (useful for debugging)
  • added openapi doc for the new API

image

Sample result API to get knowledge panels for a tag:

image

@stephanegigandet stephanegigandet requested a review from a team as a code owner July 5, 2023 15:15
@github-actions github-actions bot added API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling 🧪 tests 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org labels Jul 5, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jul 10, 2023

Codecov Report

Merging #8662 (4591178) into main (39560c8) will decrease coverage by 0.01%.
Report is 29 commits behind head on main.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main    #8662      +/-   ##
==========================================
- Coverage   48.78%   48.78%   -0.01%     
==========================================
  Files         117      118       +1     
  Lines       21882    21967      +85     
  Branches     4869     4886      +17     
==========================================
+ Hits        10676    10717      +41     
- Misses       9903     9944      +41     
- Partials     1303     1306       +3     
Files Changed Coverage Δ
lib/ProductOpener/Ecoscore.pm 75.91% <ø> (ø)
lib/ProductOpener/Ingredients.pm 90.80% <ø> (ø)
lib/ProductOpener/Routing.pm 29.62% <0.00%> (-0.48%) ⬇️
tests/unit/ingredients_processing.t 94.73% <ø> (ø)
tests/unit/packaging_stats.t 100.00% <ø> (ø)
lib/ProductOpener/API.pm 16.81% <25.00%> (+0.15%) ⬆️
lib/ProductOpener/APITagRead.pm 34.88% <34.88%> (ø)
lib/ProductOpener/PackagingStats.pm 29.85% <56.00%> (+1.13%) ⬆️
lib/ProductOpener/Packaging.pm 75.44% <93.75%> (+0.75%) ⬆️
tests/unit/packaging.t 77.04% <100.00%> (+2.04%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions github-actions bot added 📚 Documentation Documentation issues improve the project for everyone. API v3 labels Jul 25, 2023
@stephanegigandet stephanegigandet changed the title feat: compute stats for the main material of the packaging - work in progress feat: compute stats for the main material of the packaging Jul 25, 2023
Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (kudos for that's not easy work)

I only ask for one some small refactoring, if possible !

lib/ProductOpener/Packaging.pm Show resolved Hide resolved
lib/ProductOpener/APITagRead.pm Show resolved Hide resolved
lib/ProductOpener/APITagRead.pm Show resolved Hide resolved
lib/ProductOpener/PackagingStats.pm Outdated Show resolved Hide resolved
@github-actions github-actions bot added the 🌱 Eco-Score https://world.openfoodfacts.org/eco-score-the-environmental-impact-of-food-products label Jul 31, 2023
@sonarcloud
Copy link

sonarcloud bot commented Aug 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@stephanegigandet stephanegigandet merged commit be14720 into main Aug 1, 2023
16 checks passed
@stephanegigandet stephanegigandet deleted the packagings_materials_main branch August 1, 2023 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API v3 API Issues related to the Open Food Facts API. More specific labels exist & should be used (API WRITE…) 📚 Documentation Documentation issues improve the project for everyone. 🌱 Eco-Score https://world.openfoodfacts.org/eco-score-the-environmental-impact-of-food-products 📖 Knowledge Panels https://wiki.openfoodfacts.org/Knowledge_panels 📦 Packaging https://wiki.openfoodfacts.org/Category:Recycling Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. 🧪 tests Translations We use a non-standard version of GetText, lack language variants support translate.openfoodfacts.org
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants